﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace Projeto3D
{
    class ItensManager
    {
        public Model itensModel;
        public List<Itens> listaItens = new List<Itens>();
        public Itens itens;
        //public Personagem3D personagem;
        public TimeSpan removeTime,removeTimeMax;
       
        
       


        public ItensManager(Model itensModel)
        {
            this.itensModel = itensModel;
           
            removeTime = TimeSpan.FromMilliseconds(0);
            removeTimeMax = TimeSpan.FromSeconds(10);
            

        }


        public void AddItens(float x, float z)
        {
                itens = new Itens(itensModel);
            
                itens.position.X = x;
                itens.position.Z = z;

                listaItens.Add(itens);
                            
            }
            
          
            
       
        public void removeItens()
        {
            
            if(removeTime > removeTimeMax)
            {
                listaItens.Remove(itens);
                removeTime = TimeSpan.FromMilliseconds(0);
                
            }
        }

        

        public void Draw(Camera3D camera)
        {
            for (int i = 0; i < listaItens.Count; i++)
            {
                listaItens[i].draw(camera);
            }

            
        }

        public void update(GameTime gametime, float x, float z)
        {
            removeTime += gametime.ElapsedGameTime;
            AddItens(x, z);
            removeItens();

        }
    }
}
